package com.colodoo.framework.common;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author zhisan
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Result<T> {
	private Boolean success;
	private Integer code;
	private String msg;
	private T data;

	public static Result ok() {
		return new Result(true, 000000, "操作成功", null);
	}

	public static <T> Result ok(T data) {
		return new Result(true, 000000, "操作成功", data);
	}

	public Result data(T data) {
		this.setData(data);
		return this;
	}

	public static Result err(String msg) {
		return new Result(false, 999999, msg, null);
	}

	public static Result err(Integer code, String msg) {
		return new Result(false, code, msg, null);
	}

	public static Result err() {
		return new Result(false, 999999, "操作失败", null);
	}
}
